<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class MoreThread extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:morethread';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }
    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {   
        $begin = 1519;
        $end = 1998;
        $url = '127.0.0.1?action=baidu&begin='.$begin.'&end='.$end; 
        $this->doRequest($url); 
        $url = '127.0.0.1?action=360&begin='.$begin.'&end='.$end; 
        $this->doRequest($url); 
        $url = '127.0.0.1?action=iask&begin='.$begin.'&end='.$end; 
        $this->doRequest($url); 
        // for($i=0;$i<22;$i++){
        //     $begin = $i*$num;
        //     $end = ($i+1)*$num; 
        //     $url = '127.0.0.1?action=baidu&begin='.$begin.'&end='.$end; 
        //     $this->doRequest($url); 
        //     $url = '127.0.0.1?action=360&begin='.$begin.'&end='.$end; 
        //     $this->doRequest($url); 
        //     $url = '127.0.0.1?action=iask&begin='.$begin.'&end='.$end; 
        //     $this->doRequest($url); 
        // }
        // $url = '127.0.0.1?leju_begin=1&leju_end=591'; 
        // $this->doRequest($url); 
        // $num = 1000;
        // for($i=0;$i<11;$i++){
        //     $begin = $i*$num;
        //     $end = ($i+1)*$num; 
        //     $url = '127.0.0.1?leju_begin='.$begin.'&leju_end='.$end; 
        //     $this->doRequest($url); 
        // }     
        // $url = '127.0.0.1?action=bjxiaoqu';   
        // $this->doRequest($url);   
    }
   public function doRequest($url){   

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_TIMEOUT,2);
        $output = curl_exec($ch);
        $error = curl_error($ch);
        curl_close($ch);
    } 
  
}
